<?php

class Account {

    var $_member_mod;

    function __construct() {
        $this->_member_mod = & m('member');
    }
    
    /**
     * 扣除佣金
     */
    function trade_charges($order_info) {
        //未开启
        if (!Conf::get('payment_trade_charges_ratio')) {
            return true;
        }
        $payment_trade_charges_ratio = Conf::get('payment_trade_charges_ratio');
  
        //当前佣金
        $member_trade_charges = round($order_info['goods_amount'] * $payment_trade_charges_ratio, 2);
        if ($member_trade_charges<=0) {
            return true;
        }
        
        //卖家当前信息
        $seller_info = $this->_member_mod->get($order_info['seller_id']);
        $add_account_log = array(
            'user_id' => $seller_info['user_id'],
            'user_name' => $seller_info['user_name'],
            'order_sn' => $order_info['order_sn'],
            'add_time' => gmtime(),
            'type' => ACCOUNT_TYPE_TRADE_CHARGES, 
            'money_flow' => 'outlay',//转出	
            'money' => $member_trade_charges,
            'complete' => 1,
            'log_text' => "扣除交易佣金-你有一笔订单交易成功,扣除佣金".$member_trade_charges.",订单号为:".$order_info['order_sn']."商品金额为：".$order_info['goods_amount'].",佣金比例为".$payment_trade_charges_ratio,
            'states' => ACCOUNT_TYPE_TRADE_CHARGES,
        );
        $mysql_flag=$this->_member_mod->change_money($add_account_log);
        return $mysql_flag;
    }
}

?>
